package com.candy.test;

import com.candy.bean.ListTypeDiDemo;
import com.candy.service.AccountService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Client3 {
    @Test
    public void test01(){
//        加载容器
//        ClassPathXmlApplicationContext：可以加载类路径下的配置文件
        ApplicationContext ac=new ClassPathXmlApplicationContext("application.xml");
//       调用getBean方法进行对象创建
        AccountService accountService=(AccountService) ac.getBean("accountService");
        System.out.println(accountService);
        accountService.save();
        AccountService accountService2=(AccountService) ac.getBean("accountService");
        System.out.println(accountService2);
        System.out.println(accountService==accountService2);

    }
    @Test
    public void test02(){
//        加载容器
//        ClassPathXmlApplicationContext：可以加载类路径下的配置文件
        ClassPathXmlApplicationContext ac=new ClassPathXmlApplicationContext("application.xml");
//       调用getBean方法进行对象创建
        AccountService accountService=(AccountService) ac.getBean("accountService");
        System.out.println(accountService);
        accountService.save();
        AccountService accountService2=(AccountService) ac.getBean("accountService");
        System.out.println(accountService2);
        System.out.println(accountService==accountService2);
  ac.close();
    }
}

